<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/20
 * Time: 10:52
 */

namespace app\crm\model;


use think\Db;

class Help
{
    public static $table = 'help';

    public static function pagination($where = [], $pageSize = 10)
    {
        $db = Db::name(self::$table);
        return $db->order('id', 'desc')->paginate($pageSize);
    }

    public static function one($where = [])
    {
        $db = Db::name(self::$table);
        if (empty($where)) {
            throw new \Exception("查询条件为空");
        }
        if (isset($where['id'])) {
            $db->where('id', $where['id']);
        }

        return $db->limit(1)->find();
    }

    public static function insert($data)
    {
        return Db::name(self::$table)->insert($data);
    }

    public static function del($where = [])
    {
        return Db::name(static::$table)->delete($where);
    }


}